#include "head.h"

MYSQL *conn_ptr;

int main() {
    conn_ptr = connectDB("47.99.207.120", "root", "0331", "server_monitor", 0);
    if (!conn_ptr) {
        fprintf(stderr, "connection failed!\n");
        exit(EXIT_FAILURE);
    }
    int res;
    // if (res = (mysql_query(conn_ptr, "INSERT INTO slaveInfo (name, ip) VALUES ('aliyun3', '11.52.66.38')"))) {
    //     fprintf(stderr, "SELECT error: %s\n", mysql_error(conn_ptr));
    //     exit(EXIT_FAILURE);        
    // }
    struct slaveInfo si = {0, "aliyun4", "12.4.95.100", NULL};
    if (res = insert_slaveInfo(si)) {
        fprintf(stderr, "SELECT error: %s\n", mysql_error(conn_ptr));
        exit(EXIT_FAILURE);        
    }
    printf("Inserted %lu rows\n",(unsigned long)mysql_affected_rows(conn_ptr)); 
    mysql_close(conn_ptr);  

    return 0;
}